define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'hotel/cyshops/index' + location.search,
                    add_url: 'hotel/cyshops/add',
                    edit_url: 'hotel/cyshops/edit',
                    del_url: 'hotel/cyshops/del',
                    multi_url: 'hotel/cyshops/multi',
                    import_url: 'hotel/cyshops/import',
                    table: 'hotel_cy_shops',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'manage_type_name', title: __('Manage_type_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'brand_code', title: __('Brand_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'shop_code', title: __('Shop_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'crm_company_id', title: __('Crm_company_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'gc_id', title: __('Gc_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'contact_tel', title: __('Contact_tel'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'open_time', title: __('Open_time'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'mc_id', title: __('Mc_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'coop_center_id', title: __('Coop_center_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'county_id', title: __('County_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'city_name', title: __('City_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'tax_number', title: __('Tax_number'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'region_name', title: __('Region_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'gc_x', title: __('Gc_x'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'gc_y', title: __('Gc_y'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'sly_code', title: __('Sly_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'region_id', title: __('Region_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'brand_name', title: __('Brand_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'shop_name', title: __('Shop_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'county_name', title: __('County_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'crm_shop_id', title: __('Crm_shop_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'province_name', title: __('Province_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'brand_id', title: __('Brand_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'shop_id', title: __('Shop_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'province_id', title: __('Province_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'manage_type_id', title: __('Manage_type_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'city_id', title: __('City_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
